/* Project: POPS
 * CS 279, Vanderbilt University
 * by: Igor I. Ges, Michael S. Parrish, Mark E. Sakauye
 *
 *  This program is free software: you can redistribute it and/or modify
 *   it under the terms of the GNU General Public License as published by
 *   the Free Software Foundation, either version 3 of the License, or
 *   (at your option) any later version.
 *
 *   This program is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *   GNU General Public License for more details.
 *
 *   You should have received a copy of the GNU General Public License
 *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

package com.popsGUI.java;

import java.awt.event.KeyEvent;
import java.text.DateFormat;
import java.text.DecimalFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;

import com.popsDB.java.dao.CustomersDao;
import com.popsDB.java.dao.ItemsDao;
import com.popsDB.java.dao.OrdereditemsDao;
import com.popsDB.java.dao.OrdersDao;
import com.popsDB.java.dto.Employee;
import com.popsDB.java.dto.Positions;
import com.popsDB.java.dto.Items;
import com.popsDB.java.dto.Ordereditems;
import com.popsDB.java.dto.Orders;
import com.popsDB.java.factory.CustomersDaoFactory;
import com.popsDB.java.factory.ItemsDaoFactory;
import com.popsDB.java.factory.OrdereditemsDaoFactory;
import com.popsDB.java.factory.OrdersDaoFactory;
import com.popsDB.java.factory.PositionsDaoFactory;

public class popsGUIMainMenu extends javax.swing.JFrame {

	/** Creates new form popsGUIMainMenu */
	public popsGUIMainMenu() {
		initComponents();
		notificationDialog = new com.popsGUI.java.notificationDialog(null,false);
	}

	//GEN-BEGIN:initComponents
	// <editor-fold defaultstate="collapsed" desc="Generated Code">
	private void initComponents() {
		mainLayeredPane = new javax.swing.JLayeredPane();
		blankPanel = new javax.swing.JPanel();
		orderPanel = new com.popsGUI.java.OrderPanel();
		customerPanel = new com.popsGUI.java.CustomerPanel();
		editMasterPriceSheet = new com.popsGUI.java.EditMasterPriceSheet();
		itemPanel = new com.popsGUI.java.ItemPanel();
		priceSheetPanel = new com.popsGUI.java.PriceSheetPanel();
		employeePanel = new com.popsGUI.java.EmployeePanel();
		loginPanel = new javax.swing.JPanel();
		lp_username_label = new javax.swing.JLabel();
		lp_password_label = new javax.swing.JLabel();
		lp_login_button = new javax.swing.JButton();
		lp_username_field = new javax.swing.JTextField();
		lp_password_field = new javax.swing.JPasswordField();
		reportsPanel = new com.popsGUI.java.ReportsPanel();
		menuBar = new javax.swing.JMenuBar();
		fileMenu = new javax.swing.JMenu();
		openMenuItem = new javax.swing.JMenuItem();
		saveMenuItem = new javax.swing.JMenuItem();
		saveAsMenuItem = new javax.swing.JMenuItem();
		logoutMenuItem = new javax.swing.JMenuItem();
		exitMenuItem = new javax.swing.JMenuItem();
		editMenu = new javax.swing.JMenu();
		cutMenuItem = new javax.swing.JMenuItem();
		copyMenuItem = new javax.swing.JMenuItem();
		pasteMenuItem = new javax.swing.JMenuItem();
		deleteMenuItem = new javax.swing.JMenuItem();
		helpMenu = new javax.swing.JMenu();
		contentsMenuItem = new javax.swing.JMenuItem();
		aboutMenuItem = new javax.swing.JMenuItem();
		orderMenu = new javax.swing.JMenu();
		orderMenu_co_item = new javax.swing.JMenuItem();
		orderMenu_eo_item = new javax.swing.JMenuItem();
		custMenu = new javax.swing.JMenu();
		custMenu_createCust_item = new javax.swing.JMenuItem();
		custMenu_editviewCust_item = new javax.swing.JMenuItem();
		itemMenu = new javax.swing.JMenu();
		itemMenu_viewItems_item = new javax.swing.JMenuItem();
		priceSheetMenu = new javax.swing.JMenu();
		priceSheetMenu_veMasterPriceSheet_item = new javax.swing.JMenuItem();
		priceSheetMenu_vieweditPriceSheet_item = new javax.swing.JMenuItem();
		employeeMenu = new javax.swing.JMenu();
		employeeMenu_createEmployee_item = new javax.swing.JMenuItem();
		employeeMenu_veEmployee_item = new javax.swing.JMenuItem();
		reportsMenu = new javax.swing.JMenu();
		rm_priceSheets_menu = new javax.swing.JMenu();
		rm_ps_printps_item = new javax.swing.JMenuItem();
		rm_orders_menu = new javax.swing.JMenu();
		rm_o_printIndOrder_item = new javax.swing.JMenuItem();
		rm_customers_menu = new javax.swing.JMenu();
		rm_c_printCustList_item = new javax.swing.JMenuItem();

		setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

		javax.swing.GroupLayout blankPanelLayout = new javax.swing.GroupLayout(
				blankPanel);
		blankPanel.setLayout(blankPanelLayout);
		blankPanelLayout.setHorizontalGroup(blankPanelLayout
				.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
				.addGap(0, 1024, Short.MAX_VALUE));
		blankPanelLayout.setVerticalGroup(blankPanelLayout.createParallelGroup(
				javax.swing.GroupLayout.Alignment.LEADING).addGap(0, 679,
				Short.MAX_VALUE));

		blankPanel.setBounds(0, 0, 1024, 679);
		mainLayeredPane.add(blankPanel, new Integer(1));
		orderPanel.setBounds(0, 0, 1024, 679);
		mainLayeredPane.add(orderPanel, new Integer(1));
		customerPanel.setBounds(0, 0, 1024, 679);
		mainLayeredPane.add(customerPanel, new Integer(1));
		editMasterPriceSheet.setBounds(0, 0, 1024, 679);
		mainLayeredPane.add(editMasterPriceSheet, new Integer(1));
		itemPanel.setBounds(0, 0, 1024, 679);
		mainLayeredPane.add(itemPanel, new Integer(1));
		priceSheetPanel.setBounds(0, 0, 1024, 679);
		mainLayeredPane.add(priceSheetPanel, new Integer(1));
		employeePanel.setBounds(0, 0, 1024, 679);
		mainLayeredPane.add(employeePanel, new Integer(1));

		loginPanel.setMinimumSize(new java.awt.Dimension(1024, 679));
		loginPanel.setPreferredSize(new java.awt.Dimension(1024, 679));

		lp_username_label.setText("Username");

		lp_password_label.setText("Password");

		lp_login_button.setMnemonic(KeyEvent.VK_L);
		lp_login_button.setFocusCycleRoot(true);
		lp_login_button.setFocusTraversalPolicyProvider(true);
		lp_login_button.setLabel("Login");
		lp_login_button.addActionListener(new java.awt.event.ActionListener() {
			public void actionPerformed(java.awt.event.ActionEvent evt) {
				lp_login_buttonActionPerformed(evt);
			}
		});

		javax.swing.GroupLayout loginPanelLayout = new javax.swing.GroupLayout(
				loginPanel);
		loginPanel.setLayout(loginPanelLayout);
		loginPanelLayout
				.setHorizontalGroup(loginPanelLayout
						.createParallelGroup(
								javax.swing.GroupLayout.Alignment.LEADING)
						.addGroup(
								loginPanelLayout
										.createSequentialGroup()
										.addGap(414, 414, 414)
										.addGroup(
												loginPanelLayout
														.createParallelGroup(
																javax.swing.GroupLayout.Alignment.TRAILING)
														.addComponent(
																lp_password_label)
														.addComponent(
																lp_username_label))
										.addPreferredGap(
												javax.swing.LayoutStyle.ComponentPlacement.RELATED)
										.addGroup(
												loginPanelLayout
														.createParallelGroup(
																javax.swing.GroupLayout.Alignment.LEADING,
																false)
														.addComponent(
																lp_password_field)
														.addComponent(
																lp_username_field,
																javax.swing.GroupLayout.DEFAULT_SIZE,
																148,
																Short.MAX_VALUE))
										.addContainerGap(404, Short.MAX_VALUE))
						.addGroup(
								javax.swing.GroupLayout.Alignment.TRAILING,
								loginPanelLayout.createSequentialGroup()
										.addContainerGap(489, Short.MAX_VALUE)
										.addComponent(lp_login_button).addGap(
												472, 472, 472)));
		loginPanelLayout
				.setVerticalGroup(loginPanelLayout
						.createParallelGroup(
								javax.swing.GroupLayout.Alignment.LEADING)
						.addGroup(
								loginPanelLayout
										.createSequentialGroup()
										.addGap(285, 285, 285)
										.addGroup(
												loginPanelLayout
														.createParallelGroup(
																javax.swing.GroupLayout.Alignment.BASELINE)
														.addComponent(
																lp_username_label)
														.addComponent(
																lp_username_field,
																javax.swing.GroupLayout.PREFERRED_SIZE,
																javax.swing.GroupLayout.DEFAULT_SIZE,
																javax.swing.GroupLayout.PREFERRED_SIZE))
										.addPreferredGap(
												javax.swing.LayoutStyle.ComponentPlacement.RELATED)
										.addGroup(
												loginPanelLayout
														.createParallelGroup(
																javax.swing.GroupLayout.Alignment.BASELINE)
														.addComponent(
																lp_password_label)
														.addComponent(
																lp_password_field,
																javax.swing.GroupLayout.PREFERRED_SIZE,
																javax.swing.GroupLayout.DEFAULT_SIZE,
																javax.swing.GroupLayout.PREFERRED_SIZE))
										.addPreferredGap(
												javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
										.addComponent(lp_login_button)
										.addContainerGap(307, Short.MAX_VALUE)));

		loginPanel.setBounds(0, 0, 1024, 679);
		mainLayeredPane.add(loginPanel, new Integer(2));

		reportsPanel.setMinimumSize(new java.awt.Dimension(1024, 679));
		reportsPanel.setBounds(0, 0, 1024, 679);
		mainLayeredPane.add(reportsPanel, new Integer(1));

		fileMenu.setMnemonic(KeyEvent.VK_F);
		fileMenu.setText("File");

		openMenuItem.setText("Open");
		openMenuItem.setEnabled(false);
		fileMenu.add(openMenuItem);

		saveMenuItem.setText("Save");
		saveMenuItem.setEnabled(false);
		fileMenu.add(saveMenuItem);

		saveAsMenuItem.setText("Save As ...");
		saveAsMenuItem.setEnabled(false);
		fileMenu.add(saveAsMenuItem);

		logoutMenuItem.setMnemonic(KeyEvent.VK_L);
		logoutMenuItem.setText("Logout");
		logoutMenuItem.addActionListener(new java.awt.event.ActionListener() {
			public void actionPerformed(java.awt.event.ActionEvent evt) {
				logoutMenuItemActionPerformed(evt);
			}
		});
		fileMenu.add(logoutMenuItem);

		exitMenuItem.setMnemonic(KeyEvent.VK_E);
		exitMenuItem.setText("Exit");
		exitMenuItem.addActionListener(new java.awt.event.ActionListener() {
			public void actionPerformed(java.awt.event.ActionEvent evt) {
				exitMenuItemActionPerformed(evt);
			}
		});
		fileMenu.add(exitMenuItem);

		menuBar.add(fileMenu);

		editMenu.setText("Edit");
		editMenu.setEnabled(false);

		cutMenuItem.setText("Cut");
		editMenu.add(cutMenuItem);

		copyMenuItem.setText("Copy");
		editMenu.add(copyMenuItem);

		pasteMenuItem.setText("Paste");
		editMenu.add(pasteMenuItem);

		deleteMenuItem.setText("Delete");
		editMenu.add(deleteMenuItem);

		menuBar.add(editMenu);

		helpMenu.setText("Help");
		helpMenu.setEnabled(false);

		contentsMenuItem.setText("Contents");
		helpMenu.add(contentsMenuItem);

		aboutMenuItem.setText("About");
		helpMenu.add(aboutMenuItem);

		menuBar.add(helpMenu);

		orderMenu.setMnemonic(KeyEvent.VK_O);
		orderMenu.setText("Order");
		orderMenu.setEnabled(false);

		orderMenu_co_item.setMnemonic(KeyEvent.VK_O);
		orderMenu_co_item.setText("Create Order");
		orderMenu_co_item
				.addActionListener(new java.awt.event.ActionListener() {
					public void actionPerformed(java.awt.event.ActionEvent evt) {
						orderMenu_co_itemActionPerformed(evt);
					}
				});
		orderMenu.add(orderMenu_co_item);

		orderMenu_eo_item.setMnemonic(KeyEvent.VK_V);
		orderMenu_eo_item.setText("View/Edit Order");
		orderMenu_eo_item
				.addActionListener(new java.awt.event.ActionListener() {
					public void actionPerformed(java.awt.event.ActionEvent evt) {
						orderMenu_eo_itemActionPerformed(evt);
					}
				});
		orderMenu.add(orderMenu_eo_item);

		menuBar.add(orderMenu);

		custMenu.setMnemonic(KeyEvent.VK_C);
		custMenu.setText("Customer");
		custMenu.setEnabled(false);

		custMenu_createCust_item.setMnemonic(KeyEvent.VK_C);
		custMenu_createCust_item.setText("Create Customer");
		custMenu_createCust_item
				.addActionListener(new java.awt.event.ActionListener() {
					public void actionPerformed(java.awt.event.ActionEvent evt) {
						custMenu_createCust_itemActionPerformed(evt);
					}
				});
		custMenu.add(custMenu_createCust_item);

		custMenu_editviewCust_item.setMnemonic(KeyEvent.VK_V);
		custMenu_editviewCust_item.setText("View/Edit Customer");
		custMenu_editviewCust_item
				.addActionListener(new java.awt.event.ActionListener() {
					public void actionPerformed(java.awt.event.ActionEvent evt) {
						custMenu_editviewCust_itemActionPerformed(evt);
					}
				});
		custMenu.add(custMenu_editviewCust_item);

		menuBar.add(custMenu);

		itemMenu.setMnemonic(KeyEvent.VK_I);
		itemMenu.setText("Item");
		itemMenu.setEnabled(false);

		itemMenu_viewItems_item.setMnemonic(KeyEvent.VK_I);
		itemMenu_viewItems_item.setText("View Items");
		itemMenu_viewItems_item
				.addActionListener(new java.awt.event.ActionListener() {
					public void actionPerformed(java.awt.event.ActionEvent evt) {
						itemMenu_viewItems_itemActionPerformed(evt);
					}
				});
		itemMenu.add(itemMenu_viewItems_item);

		menuBar.add(itemMenu);

		priceSheetMenu.setMnemonic(KeyEvent.VK_P);
		priceSheetMenu.setText("Price Sheet");
		priceSheetMenu.setEnabled(false);

		priceSheetMenu_veMasterPriceSheet_item.setMnemonic(KeyEvent.VK_M);
		priceSheetMenu_veMasterPriceSheet_item
				.setText("View/Edit Master Price Sheet");
		priceSheetMenu_veMasterPriceSheet_item
				.addActionListener(new java.awt.event.ActionListener() {
					public void actionPerformed(java.awt.event.ActionEvent evt) {
						priceSheetMenu_veMasterPriceSheet_itemActionPerformed(evt);
					}
				});
		priceSheetMenu.add(priceSheetMenu_veMasterPriceSheet_item);

		priceSheetMenu_vieweditPriceSheet_item.setMnemonic(KeyEvent.VK_P);
		priceSheetMenu_vieweditPriceSheet_item.setText("View/Edit Price Sheet");
		priceSheetMenu_vieweditPriceSheet_item
				.addActionListener(new java.awt.event.ActionListener() {
					public void actionPerformed(java.awt.event.ActionEvent evt) {
						priceSheetMenu_vieweditPriceSheet_itemActionPerformed(evt);
					}
				});
		priceSheetMenu.add(priceSheetMenu_vieweditPriceSheet_item);

		menuBar.add(priceSheetMenu);

		employeeMenu.setMnemonic(KeyEvent.VK_E);
		employeeMenu.setText("Employee");
		employeeMenu.setEnabled(false);

		employeeMenu_createEmployee_item.setMnemonic(KeyEvent.VK_E);
		employeeMenu_createEmployee_item.setText("Create Employee");
		employeeMenu_createEmployee_item
				.addActionListener(new java.awt.event.ActionListener() {
					public void actionPerformed(java.awt.event.ActionEvent evt) {
						employeeMenu_createEmployee_itemActionPerformed(evt);
					}
				});
		employeeMenu.add(employeeMenu_createEmployee_item);

		employeeMenu_veEmployee_item.setMnemonic(KeyEvent.VK_V);
		employeeMenu_veEmployee_item.setText("View/Edit Employee");
		employeeMenu_veEmployee_item
				.addActionListener(new java.awt.event.ActionListener() {
					public void actionPerformed(java.awt.event.ActionEvent evt) {
						employeeMenu_veEmployee_itemActionPerformed(evt);
					}
				});
		employeeMenu.add(employeeMenu_veEmployee_item);

		menuBar.add(employeeMenu);

		reportsMenu.setMnemonic(KeyEvent.VK_R);
		reportsMenu.setText("Reports");
		reportsMenu.setEnabled(false);

		rm_priceSheets_menu.setMnemonic(KeyEvent.VK_P);
		rm_priceSheets_menu.setText("Price Sheets");

		rm_ps_printps_item.setMnemonic(KeyEvent.VK_P);
		rm_ps_printps_item.setText("Print Price Sheet");
		rm_ps_printps_item
				.addActionListener(new java.awt.event.ActionListener() {
					public void actionPerformed(java.awt.event.ActionEvent evt) {
						rm_ps_printps_itemActionPerformed(evt);
					}
				});
		rm_priceSheets_menu.add(rm_ps_printps_item);

		reportsMenu.add(rm_priceSheets_menu);

		rm_orders_menu.setMnemonic(KeyEvent.VK_O);
		rm_orders_menu.setText("Orders");

		rm_o_printIndOrder_item.setMnemonic(KeyEvent.VK_O);
		rm_o_printIndOrder_item.setText("Print Individual Order");
		rm_o_printIndOrder_item
				.addActionListener(new java.awt.event.ActionListener() {
					public void actionPerformed(java.awt.event.ActionEvent evt) {
						rm_o_printIndOrder_itemActionPerformed(evt);
					}
				});
		rm_orders_menu.add(rm_o_printIndOrder_item);

		reportsMenu.add(rm_orders_menu);

		rm_customers_menu.setMnemonic(KeyEvent.VK_C);
		rm_customers_menu.setText("Customers");

		rm_c_printCustList_item.setMnemonic(KeyEvent.VK_C);
		rm_c_printCustList_item.setText("Print Customer List");
		rm_c_printCustList_item
				.addActionListener(new java.awt.event.ActionListener() {
					public void actionPerformed(java.awt.event.ActionEvent evt) {
						rm_c_printCustList_itemActionPerformed(evt);
					}
				});
		rm_customers_menu.add(rm_c_printCustList_item);

		reportsMenu.add(rm_customers_menu);

		menuBar.add(reportsMenu);

		setJMenuBar(menuBar);

		javax.swing.GroupLayout layout = new javax.swing.GroupLayout(
				getContentPane());
		getContentPane().setLayout(layout);
		layout.setHorizontalGroup(layout.createParallelGroup(
				javax.swing.GroupLayout.Alignment.LEADING).addComponent(
				mainLayeredPane, javax.swing.GroupLayout.DEFAULT_SIZE, 1024,
				Short.MAX_VALUE));
		layout.setVerticalGroup(layout.createParallelGroup(
				javax.swing.GroupLayout.Alignment.LEADING).addComponent(
				mainLayeredPane, javax.swing.GroupLayout.DEFAULT_SIZE, 681,
				Short.MAX_VALUE));

		pack();
	}// </editor-fold>
	//GEN-END:initComponents

	private void rm_ps_printps_itemActionPerformed(
			java.awt.event.ActionEvent evt) {
		// TODO add your handling code here:
		this.reportsPanel.showPriceSheetSelectionDialog();
		this.reportsPanel.fillPSSD_comboboxes();
	}

	private void rm_o_printIndOrder_itemActionPerformed(
			java.awt.event.ActionEvent evt) {
		// TODO add your handling code here:
		this.reportsPanel.showIndOrderSelectionDialog();
		this.reportsPanel.fillIOSDCustCombobox();
	}

	private void rm_c_printCustList_itemActionPerformed(
			java.awt.event.ActionEvent evt) {
		// TODO add your handling code here:
		this.reportsPanel.printCustList();
	}

	private void logoutMenuItemActionPerformed(java.awt.event.ActionEvent evt) {
		// TODO add your handling code here:
		userID = -1;
		lp_username_field.setText("");
		lp_password_field.setText("");
		lp_username_field.grabFocus();
		orderMenu.setEnabled(false);
		custMenu.setEnabled(false);
		itemMenu.setEnabled(false);
		priceSheetMenu.setEnabled(false);
		employeeMenu.setEnabled(false);
		reportsMenu.setEnabled(false);
		this.setLoginPanelOnTop();
	}

	private void lp_login_buttonActionPerformed(java.awt.event.ActionEvent evt) {
		// TODO add your handling code here:
		// Right now you're logged in as soon as you click the login button
		// No checking yet; to be added soon...

		int posID = MEDIATOR.checkEmployeeLogin(lp_username_field.getText()
				.toString(), lp_password_field.getText().toString());

		System.out.println("POSITION ID: " + posID);
		if (posID != -1) {
			String perm = MEDIATOR.getPositionPermissions(posID);
			if (perm.charAt(0) == '0') {
				orderMenu_co_item.setEnabled(false);
			} else if (perm.charAt(0) == '1') {
				orderMenu_co_item.setEnabled(true);
			}
			if (perm.charAt(1) == '0') {
				orderMenu_eo_item.setEnabled(false);
			} else if (perm.charAt(1) == '1') {
				orderMenu_eo_item.setEnabled(true);
			}
			if (perm.charAt(0) == '0' && perm.charAt(1) == '0') {
				orderMenu.setEnabled(false);
			} else {
				orderMenu.setEnabled(true);
			}

			if (perm.charAt(2) == '0') {
				custMenu_createCust_item.setEnabled(false);
			} else if (perm.charAt(2) == '1') {
				custMenu_createCust_item.setEnabled(true);
			}
			if (perm.charAt(3) == '0') {
				custMenu_editviewCust_item.setEnabled(false);
			} else if (perm.charAt(3) == '1') {
				custMenu_editviewCust_item.setEnabled(true);
			}
			if (perm.charAt(2) == '0' && perm.charAt(3) == '0') {
				custMenu.setEnabled(false);
			} else {
				custMenu.setEnabled(true);
			}

			if (perm.charAt(4) == '0') {
				itemMenu.setEnabled(false);
			} else if (perm.charAt(4) == '1') {
				itemMenu.setEnabled(true);
			}

			if (perm.charAt(5) == '0') {
				priceSheetMenu_veMasterPriceSheet_item.setEnabled(false);
			} else if (perm.charAt(5) == '1') {
				priceSheetMenu_veMasterPriceSheet_item.setEnabled(true);
			}
			if (perm.charAt(6) == '0') {
				priceSheetMenu_vieweditPriceSheet_item.setEnabled(false);
			} else if (perm.charAt(6) == '1') {
				priceSheetMenu_vieweditPriceSheet_item.setEnabled(true);
			}
			if (perm.charAt(5) == '0' && perm.charAt(6) == '0') {
				priceSheetMenu.setEnabled(false);
			} else {
				priceSheetMenu.setEnabled(true);
			}

			if (perm.charAt(7) == '0') {
				employeeMenu_createEmployee_item.setEnabled(false);
			} else if (perm.charAt(7) == '1') {
				employeeMenu_createEmployee_item.setEnabled(true);
			}
			if (perm.charAt(8) == '0') {
				employeeMenu_veEmployee_item.setEnabled(false);
			} else if (perm.charAt(8) == '1') {
				employeeMenu_veEmployee_item.setEnabled(true);
			}
			if (perm.charAt(7) == '0' && perm.charAt(8) == '0') {
				employeeMenu.setEnabled(false);
			} else {
				employeeMenu.setEnabled(true);
			}

			if (perm.charAt(9) == '0') {
				reportsMenu.setEnabled(false);
			} else if (perm.charAt(9) == '1') {
				reportsMenu.setEnabled(true);
			}

			userID = posID;
						this.setMainMenuLayerTo1();
						this.setBlankPanelOnTop();
			

		} else {
			notificationDialog
					.displayNotification("Invalid Username or Passowrd; <br> Please Try again");
			this.lp_username_field.setText("");
			
		}
	}

	private void employeeMenu_veEmployee_itemActionPerformed(
			java.awt.event.ActionEvent evt) {
		this.setEmployeePanelOnTop();
		employeePanel.setNewEmployee();
		employeePanel.showSelectEmployeeDialog(true);
		employeePanel.updateSelectEmployeeCombobox();
	}

	private void employeeMenu_createEmployee_itemActionPerformed(
			java.awt.event.ActionEvent evt) {
		this.setEmployeePanelOnTop();
		employeePanel.setNewEmployee();
	}

	private void priceSheetMenu_veMasterPriceSheet_itemActionPerformed(
			java.awt.event.ActionEvent evt) {
		this.setEditMasterPriceSheetOnTop();
	}

	private void priceSheetMenu_vieweditPriceSheet_itemActionPerformed(
			java.awt.event.ActionEvent evt) {
		this.setPriceSheetPanelOnTop();
		priceSheetPanel.setPriceSheetPanelComponentsEnabledParameterTo(true);

	}

	private void itemMenu_viewItems_itemActionPerformed(
			java.awt.event.ActionEvent evt) {

		this.setItemPanelOnTop();

		// fill out the table
		itemPanel.fillOutTheTable();

		itemPanel.enableChangeButtons(false);
	}

	private void custMenu_editviewCust_itemActionPerformed(
			java.awt.event.ActionEvent evt) {
		customerPanel.setUnusedCustomerFieldsInvisible();
		this.setCustomerPanelOnTop();
		customerPanel.showSelectCustDialog(true);
		customerPanel.updateSelectCustomerComboboxInCUSTOMER();
	}

	private void custMenu_createCust_itemActionPerformed(
			java.awt.event.ActionEvent evt) {
		this.setCustomerPanelOnTop();
		customerPanel.setNewCustomer();
	}

	private void orderMenu_eo_itemActionPerformed(java.awt.event.ActionEvent evt) {
		this.setOrderPanelOnTop();
		orderPanel.setOrderIDField("000000");
		orderPanel.showSelectCustDialog(true);
		orderPanel.updateSelectCustomerComboboxInORDER();
	}

	private void orderMenu_co_itemActionPerformed(java.awt.event.ActionEvent evt) {
		orderPanel.setNewOrder();
		this.setOrderPanelOnTop();
		orderPanel.showSelectCustDialog(true);
		orderPanel.updateSelectCustomerComboboxInORDER();
	}

	private void exitMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_exitMenuItemActionPerformed
		System.exit(0);
	}//GEN-LAST:event_exitMenuItemActionPerformed

	/**
	 * @param args the command line arguments
	 */
	public static void main(String args[]) {
		java.awt.EventQueue.invokeLater(new Runnable() {
			public void run() {
				new popsGUIMainMenu().setVisible(true);
			}
		});
	}

	//GEN-BEGIN:variables
	// Variables declaration - do not modify
	private javax.swing.JMenuItem aboutMenuItem;
	private javax.swing.JPanel blankPanel;
	private javax.swing.JMenuItem contentsMenuItem;
	private javax.swing.JMenuItem copyMenuItem;
	private javax.swing.JMenu custMenu;
	private javax.swing.JMenuItem custMenu_createCust_item;
	private javax.swing.JMenuItem custMenu_editviewCust_item;
	private com.popsGUI.java.CustomerPanel customerPanel;
	private javax.swing.JMenuItem cutMenuItem;
	private javax.swing.JMenuItem deleteMenuItem;
	private com.popsGUI.java.EditMasterPriceSheet editMasterPriceSheet;
	private javax.swing.JMenu editMenu;
	private javax.swing.JMenu employeeMenu;
	private javax.swing.JMenuItem employeeMenu_createEmployee_item;
	private javax.swing.JMenuItem employeeMenu_veEmployee_item;
	private com.popsGUI.java.EmployeePanel employeePanel;
	private javax.swing.JMenuItem exitMenuItem;
	private javax.swing.JMenu fileMenu;
	private javax.swing.JMenu helpMenu;
	private javax.swing.JMenu itemMenu;
	private javax.swing.JMenuItem itemMenu_viewItems_item;
	private com.popsGUI.java.ItemPanel itemPanel;
	private javax.swing.JPanel loginPanel;
	private javax.swing.JMenuItem logoutMenuItem;
	private javax.swing.JButton lp_login_button;
	private javax.swing.JPasswordField lp_password_field;
	private javax.swing.JLabel lp_password_label;
	private javax.swing.JTextField lp_username_field;
	private javax.swing.JLabel lp_username_label;
	private javax.swing.JLayeredPane mainLayeredPane;
	private javax.swing.JMenuBar menuBar;
	private javax.swing.JMenuItem openMenuItem;
	private javax.swing.JMenu orderMenu;
	private javax.swing.JMenuItem orderMenu_co_item;
	private javax.swing.JMenuItem orderMenu_eo_item;
	private com.popsGUI.java.OrderPanel orderPanel;
	private javax.swing.JMenuItem pasteMenuItem;
	private javax.swing.JMenu priceSheetMenu;
	private javax.swing.JMenuItem priceSheetMenu_veMasterPriceSheet_item;
	private javax.swing.JMenuItem priceSheetMenu_vieweditPriceSheet_item;
	private com.popsGUI.java.PriceSheetPanel priceSheetPanel;
	private javax.swing.JMenu reportsMenu;
	private com.popsGUI.java.ReportsPanel reportsPanel;
	private javax.swing.JMenuItem rm_c_printCustList_item;
	private javax.swing.JMenu rm_customers_menu;
	private javax.swing.JMenuItem rm_o_printIndOrder_item;
	private javax.swing.JMenu rm_orders_menu;
	private javax.swing.JMenu rm_priceSheets_menu;
	private javax.swing.JMenuItem rm_ps_printps_item;
	private javax.swing.JMenuItem saveAsMenuItem;
	private javax.swing.JMenuItem saveMenuItem;
	// End of variables declaration//GEN-END:variables

	private com.popsGUI.java.notificationDialog notificationDialog;
	// TODO: Start of our code
	////////////////Our variable declarations /////////////////
	// CustomersDao CustomersDAO = CustomersDaoFactory.create();
	// ItemsDao ItemsDAO = ItemsDaoFactory.create();
	// OrdereditemsDao OrdereditemsDAO = OrdereditemsDaoFactory.create();
	// OrdersDao OrdersDAO = OrdersDaoFactory.create();

	Mediator MEDIATOR = Mediator.getInstance();

	DateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm");
	DecimalFormat decimalPriceFormat = new DecimalFormat("###,###,##0.00");

	// ID of the current logged in employee
	static int userID = -1;

	///////////// End of our variable declarations /////////////

	/////////////////////////////////////////////////////////////////////
	//////////////////////// Start of our code //////////////////////////
	/////////////////////////////////////////////////////////////////////

	//

	// DATE FORMAT / DATE FORMATTING
	public String getCurrentDate() {
		//Date current = new Date();
		Date date = new Date();
		return dateFormat.format(date);
	}

	//

	// Sets every component to the bottom layer and disables every interactive component
	public void setMainMenuLayerTo1() {
		mainLayeredPane.setLayer(blankPanel, 1);
		mainLayeredPane.setLayer(orderPanel, 1);
		mainLayeredPane.setLayer(customerPanel, 1);
		mainLayeredPane.setLayer(itemPanel, 1);
		mainLayeredPane.setLayer(priceSheetPanel, 1);
		mainLayeredPane.setLayer(editMasterPriceSheet, 1);
		mainLayeredPane.setLayer(employeePanel, 1);
		mainLayeredPane.setLayer(loginPanel, 1);
		mainLayeredPane.setLayer(reportsPanel, 1);

		orderPanel.setOrderPanelComponentsEnabledParameterTo(false);
		customerPanel.setCustomerPanelComponentsEnabledParameterTo(false);
		itemPanel.setItemPanelComponentsEnabledPrameterTo(false);
		priceSheetPanel.setPriceSheetPanelComponentsEnabledParameterTo(false);
		editMasterPriceSheet
				.setEditMasterPriceSheetComponentsEnabledParameterTo(false);
		employeePanel.setEmployeePanelComponentsEnabledParameterTo(false);
		this.setLoginPanelComponentsEnabledParameterTo(false);
		reportsPanel.setReportsPanelComponentsEnabledParameterTo(false);

		priceSheetPanel.reloadPSP_comboboxes();
	}

	public void setBlankPanelOnTop() {
		setMainMenuLayerTo1();
		mainLayeredPane.setLayer(blankPanel, 2);
	}

	// Sets the order panel to the top layer and enables its components
	public void setOrderPanelOnTop() {
		setMainMenuLayerTo1();
		mainLayeredPane.setLayer(orderPanel, 2);
		orderPanel.setOrderPanelComponentsEnabledParameterTo(true);
	}

	// Sets the customer panel to the top layer and enables its components
	public void setCustomerPanelOnTop() {
		setMainMenuLayerTo1();
		mainLayeredPane.setLayer(customerPanel, 2);
		customerPanel.setCustomerPanelComponentsEnabledParameterTo(true);
	}

	// Sets the item panel to the top layer and enables its components
	public void setItemPanelOnTop() {
		setMainMenuLayerTo1();
		mainLayeredPane.setLayer(itemPanel, 2);
		itemPanel.setItemPanelComponentsEnabledPrameterTo(true);
	}

	// Sets the price sheet panel to the top layer and enables its components
	public void setPriceSheetPanelOnTop() {
		setMainMenuLayerTo1();
		mainLayeredPane.setLayer(priceSheetPanel, 2);
		priceSheetPanel.setPriceSheetPanelComponentsEnabledParameterTo(true);
	}

	// Sets the edit master price sheet panel to the top layer and enables its components
	public void setEditMasterPriceSheetOnTop() {
		setMainMenuLayerTo1();
		mainLayeredPane.setLayer(editMasterPriceSheet, 2);
		editMasterPriceSheet.fillOutEMPSPTable();
		editMasterPriceSheet
				.setEditMasterPriceSheetComponentsEnabledParameterTo(true);
	}

	// Sets the employee panel to the top layer and enables its components
	public void setEmployeePanelOnTop() {
		setMainMenuLayerTo1();
		mainLayeredPane.setLayer(employeePanel, 2);
		employeePanel.setEmployeePanelComponentsEnabledParameterTo(true);
	}

	// Sets the login panel to the top layer and enables its components
	public void setLoginPanelOnTop() {
		setMainMenuLayerTo1();
		mainLayeredPane.setLayer(loginPanel, 2);
		this.setLoginPanelComponentsEnabledParameterTo(true);
	}

	// Sets the interactive components of the login panel enabled/disabled
	public void setLoginPanelComponentsEnabledParameterTo(boolean enabled) {
		lp_login_button.setEnabled(enabled);
	}

	public void setReportsPanelOnTop() {
		setMainMenuLayerTo1();
		mainLayeredPane.setLayer(reportsPanel, 2);
		reportsPanel.setReportsPanelComponentsEnabledParameterTo(true);
	}

	///////////////////////////////////////////////////////////////////
	//////////////////////// End of our code //////////////////////////
	///////////////////////////////////////////////////////////////////

}